package com.spring.lesson001.demo3;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author vhans
 */
public class Client {

    public static void main(String[] args) {
        String beanXml = "bean0013.xml";
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(beanXml);
        System.out.println("容器中的所有bean如下：");
        for (String beanName : context.getBeanDefinitionNames()) {
            System.out.println(beanName + ":" + context.getBean(beanName));
        }

        System.out.println("===============");
        // 多次获取，查看是否对应同一Bean
        System.out.println("createUserByFactoryBean:" + context.getBean("createUserByFactoryBean"));
        System.out.println("createUserByFactoryBean:" + context.getBean("createUserByFactoryBean"));
    }
}
